package be.ipl.address.domaine;

import java.io.Serializable;
import java.util.Comparator;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.SecondaryTable;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@SuppressWarnings("serial")
@Entity
@Table(name="PERSONNE", schema="ADRESSES")
@SecondaryTable(name="GSM", schema="ADRESSES")
@IdClass(PersonnePK.class)
public class Personne implements Serializable {

	@Id
	private String nom;
	@Id
	private String prenom;
	@Id
	private String pseudo;

	
	@NotNull
	@Column(table="GSM")
	private String gsm;
	@NotNull
	@Column(table="GSM")
	private String operateur;


	@NotNull
	@Embedded
	private Adresse adresse;
	
	
	public Personne(String nom, String prenom, String pseudo){
		this.nom = nom;
		this.prenom = prenom;
		this.pseudo = pseudo;
	}

	public String getGsm() {
		return gsm;
	}
	public void setGsm(String gsm) {
		this.gsm = gsm;
	}
	public String getOperateur() {
		return operateur;
	}
	public void setOperateur(String operateur) {
		this.operateur = operateur;
	}
	public String getNom() {
		return nom;
	}
	public String getPrenom() {
		return prenom;
	}
	public String getPseudo() {
		return pseudo;
	}


	public String getRueNumero() {
		return adresse.getRueNumero();
	}

	public String getCodePostal() {
		return adresse.getCodePostal();
	}

	public String getCommune() {
		return adresse.getCommune();
	}
	
	public void setRueNumero(String numero) {
		this.adresse.setRueNumero(numero);
	}
	
	public void setCodePostal(String codePostal) {
		this.adresse.setCodePostal(codePostal);
	}
	
	public void setCommune(String commune) {
		this.adresse.setCommune(commune);
	}


	public static class PersonnePseudoComparator implements Comparator<Personne>, Serializable {

		@Override
		public int compare(Personne p1, Personne p2) {
			return p1.pseudo.compareTo(p2.pseudo);
		}
		
	}
	

}
